package com.cuixichang.minimalism.core.mybatis.base;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.cuixichang.minimalism.core.mybatis.cnstants.BaseFieldNames;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class BasePo implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 唯一标识
     */
    @TableId(value = BaseFieldNames.ID, type = IdType.AUTO)
    private Long id;

    /**
     * 启用状态【0:弃用;1:启用(默认)】
     * @see com.cuixichang.minimalism.basal.enums.IsEnableEnum
     */
    @TableField(BaseFieldNames.IS_ENABLE)
    private Boolean isEnable;

    /**
     * 数据排序
     */
    @TableField(BaseFieldNames.SORT)
    private Integer sort;

    /**
     * 创建时间
     */
    @TableField(BaseFieldNames.CREATE_TIME)
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private LocalDateTime createTime;

    /**
     * 数据更新时间
     */
    @TableField(BaseFieldNames.UPDATE_TIME)
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private LocalDateTime updateTime;

    /**
     * 创建数据用户使用的登录id
     */
    @TableField(BaseFieldNames.CREATE_LOGIN_ID)
    @JsonSerialize(using= ToStringSerializer.class)
    private Long createLoginId;

    /**
     * 更新数据用户使用的登录id
     */
    @TableField(BaseFieldNames.UPDATE_LOGIN_ID)
    @JsonSerialize(using= ToStringSerializer.class)
    private Long updateLoginId;
}
